#!/usr/bin/python
import datetime,sys, xmlrpclib

def logline(line):
    try:
        wf = open('check.log','ab')
        wf.write((line + "\n").encode('utf-8'))
        wf.close()
    except Exception as e:
        print ("%s : %s" % (repr(e.__class__), str(e)))


d = datetime.date.strftime(datetime.datetime.today(),"%Y-%m-%d %H:%M:%S")
try:
    s = xmlrpclib.ServerProxy("http://localhost:8000/RPC2")
    res = s.check('')
except Exception as e:
    a = d + ' ' + ("%s : %s" % (repr(e.__class__), str(e)))
    logline(a)
    sys.exit()

a = d + ' ' + str(res)
print (a)
if res != 0:
    logline(a)
